package com.atguigu.e_loopinloop;

import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        //猜 : 键盘录入 -> Scanner
        Scanner sc = new Scanner(System.in);
        //猜的数 : 随机数 -> Random , Math.random()
        int number = (int) (Math.random() * 100) + 1;

        //用循环包裹
        while (true){
            System.out.println("请您输入您要猜的数字 : [1,100]");
            int guessNumber = sc.nextInt();

            //比较2个数
            if (guessNumber == number){
                System.out.println("恭喜您,猜中了 ! 随机生成的数是 : " + guessNumber);
                //猜中要结束循环
                break;
            } else if (guessNumber < number) {
                System.out.println("您猜的数字小了 !");
            } else {
                System.out.println("您猜的数字大了 !");
            }
        }
    }
}
